﻿import QtQuick                  2.3
import QtQuick.Controls         2.12
import QtQuick.Controls.Styles  1.4

import XUI 1.0

Button {
    id:             control

    property real _margin: XScreenTool.base

    hoverEnabled:   true
    focusPolicy:    Qt.ClickFocus
    height:         _margin * 4
    width:          _margin * 7

    property alias  source:             _image.source
    property real   imageScale:         0.6
    property bool   _showHighlight:     pressed | hovered | checked


    background: Item {
    }

    contentItem: Rectangle {
        anchors.fill:   parent
        color:          _showHighlight ? XGlobalColor.theme : "transparent"
        Row {
            height:                     parent.height
            spacing:                _margin * 0
            anchors.centerIn:       parent
            Image {
                id:                     _image
                smooth:                 true
                mipmap:                 true
                antialiasing:           true
                // color:                  checked ? "white" : "white"
                height:                 parent.height * imageScale
                width:                  height
                fillMode:               Image.PreserveAspectFit
                sourceSize.height:      height
                anchors.verticalCenter: parent.verticalCenter
            }
            Item {
                width: 1
                height: 1
            }
            XLabel {
                text:                       control.text
                color:                      "white"
                anchors.verticalCenter:     parent.verticalCenter
            }
        }
    }
}

